package com.kettle;

import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.google.common.io.Files;

public class ExcelApplication {
	public static void main(String[] args) {
		String v_fileName="C:/Users/Administrator/Desktop/金蝶数据导入/TEST.xlsx";
		WriteExcelBySheet(v_fileName);
	}
	public static void WriteExcelBySheet(String v_fileName) {
		try {
			File v_file = new File(v_fileName);
			String v_filePath= v_file.getParent()+File.separator+Files.getNameWithoutExtension(v_fileName);
			Files.createParentDirs(new File(v_filePath+File.separator+"tmp"));
			v_file = new File(v_filePath);
			if(v_file.listFiles().length>0) {
				System.out.println(v_fileName+"文件已解析");
				return;
			}
			Map<String, List<List<String>>> dataListMap3 = EasyExcelUtil.ReadExcelByString(v_fileName, "");
			for (Entry<String, List<List<String>>> entry : dataListMap3.entrySet()) {
				String sheetName = entry.getKey();// 得到工作表名称
				String fileName = v_filePath + File.separator + sheetName + ".xlsx";// 指定文件路径
				if (new File(fileName).exists()) {// 文件不存在创建
					continue;
				}
				List<List<String>> dataList = entry.getValue();// 得到工作表数据
				EasyExcelUtil.WriteExcelByString(fileName, sheetName, dataList);// 输出Excel文件
			}
		} catch (Exception e) {
			System.out.println(v_fileName);
			e.printStackTrace();
		}
	}
}
